import router from './router'
import store from './store'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

NProgress.configure({ showSpinner: false })

// 不能路不能访问
const blackList = ['/profiles', '/propsTrade/tradeenroll']

router.beforeEach(async (to, from, next) => {
  NProgress.start()

  const hasToken = store.getters.getToken

  if (hasToken) {
    next()
    NProgress.done()
  } else {
    if (blackList.includes(to.path)) {
      
      next(`/login`)
      NProgress.done()
    } else {
      next()
    }
  }
})

router.afterEach(() => {
  NProgress.done()
})
